package com.it.selfAfter.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsAutoIncrement;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsKey;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import java.util.Date;

/**
 * @Author: CaoYouGen
 * @DateTime: 2023/05/30/10:12
 * @注释: 作品收藏中间表
 **/
@Data
@Entity
@TableName("production_collect")
@Table(name = "production_collect", comment = "作品收藏中间表")//设置表名  注释
public class ProductionCollect {
    private static final long serialVersionUID = 9435278593475936L;

    @IsAutoIncrement   //自增
    @IsKey             //主键
    @TableId( value = "id", type = IdType.AUTO)
    @Id
    @Column(comment = "ID")//字段注释
    private Long id;

    /**
     * 创建时间
     */

    @Column(name = "create_time", type = MySqlTypeConstant.DATETIME, comment = "创建时间")
    private Date create_time;

    /**
     * 联系手机
     */
    @Column(name = "phone",comment = "联系手机", length = 255)
    private String phone;


    /**
     * 作品id
     */
    @Column(name = "pro_id",comment = "发布人id", length = 255)
    private String pro_id;

    /**
     * 收藏人id
     */
    @Column(name = "user_id",comment = "发布人id", length = 255)
    private String user_id;


    /**
     * 新增数据时自动添加时间
     */
    @PrePersist
    protected void onCreate() {
        create_time = new Date();
    }
}
